
const app = getApp()
Page({
    data: {
        pageNum:1,
        pageTotal:0,
        mall_list: [],
        mall: {}
    },
    onLoad: function (options) {
        this.getGoodsList(options.id)
        this.getGoodsDetail(options.id)
    },
    getGoodsList(typeId) {
        let _this = this;
        app.util.request({
            url: "api/mall/findByTypeId",
            method: "post",
            data: {
                typeId: typeId,
                page: _this.data.pageNum,
                pageSize: 10
            },
            success(response) {
                if (response.data.code == 0) {
                    _this.setData({
                        pageTotal:response.data.data.pages,
                        mall_list: [..._this.data.mall_list,...response.data.data.list]
                    })
                }
            }
        })
    },
    getGoodsDetail(typeId) {
        let _this = this;
        app.util.request({
            url: "api/type/find",
            method: "post",
            data: {
                id: typeId
            },
            success(response) {
                if (response.data.code == 0) {
                    _this.setData({
                        mall: response.data.data
                    })
                }
            }
        })
    },
    toPersonalGoods(e) {
        wx.navigateTo({
            url: '/pages/goods/goods-detail/goods-detail?id=' + e.currentTarget.dataset.id,
        })
    },
})
